#include "DerivationTree.h"
#include "CallInstruction.h"

FunctionCallNode::FunctionCallNode() : NodeTree_CRTP<FunctionCallNode>(), buffer(0), length(0) { }

FunctionCallNode::FunctionCallNode(char* _buffer, unsigned int _length) : NodeTree_CRTP<FunctionCallNode>(), buffer(_buffer), length(_length) { }

FunctionCallNode::FunctionCallNode(const FunctionCallNode& copy) : NodeTree_CRTP<FunctionCallNode>(copy) {
	length = copy.length;
	buffer = new char[length];
	for (unsigned int i = 0; i < length; ++i) buffer[i] = copy.buffer[i];
}

std::string FunctionCallNode :: getName() const {
	return std::string(buffer);
}

bool FunctionCallNode :: execute(Pointer<LeonardVirtualMachine> LVM) {
	AutoPointer<TreeExpression::Expression> function(new TreeExpression::CallInstruction(std::string(buffer)));
	LVM->push(function);
	return true;
}
